package com.shenmazong.demodelayqueuetask.service;

import com.shenmazong.demodelayqueuetask.utils.MqConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @program: server-java-demo
 * @description: ConsumerService
 * @author: 亮子说编程
 * @create: 2020-11-02 16:08
 **/

@Slf4j
@Service
public class ConsumerService {

    @Autowired
    private ProductService producr;

    @RabbitListener(queues= MqConstant.MY_QUEUE_TWO)
    @RabbitHandler
    public void process(String content) {
        log.info("收到消息:"+content);
        log.info("延迟时间到，queueTwo开始执行 {}", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
    }
}
